package com.xiaoyu.im.request.flow;

import com.xiaoyu.im.datamodel.common.IMConstant;
import com.xiaoyu.im.request.MessageRequest;

import in.srain.cube.util.CLog;

import static com.xiaoyu.im.datamodel.MessageStatus.PREPARED;
import static com.xiaoyu.im.datamodel.MessageStatus.PREPARING;

public class BasePrepareAction implements FlowAction {

    @Override
    public void exec(MessageRequest request) {
        CLog.d(IMConstant.LOG_TAG, "prepare: %s", request);
        request.getPendingMessage().setStatus(PREPARING);

        onPrepare(request);
    }

    protected void onPrepare(MessageRequest request) {
        request.getPendingMessage().setStatus(PREPARED);
        RequestFlow.evolveToNextStatus(request);
    }
}
